package ar.edu.itba.it.paw.domain;

import java.util.Date;

public class Transaction extends PersistentAttributes {


	private User buyer;
	private User seller;
	private int quantity;
	private Date date;
	private Product product;
	
	//This constructor is used to create transactions before they are inserted into the database
	public Transaction(User buyer, User seller, int quantity, Date date, Product product) {
		if(!(buyer == null || seller == null || product == null || quantity < 0)){
			this.buyer = buyer;
			this.seller = seller;
			this.quantity = quantity;
			this.date = date;
			this.product = product;
		}else{
			throw new IllegalArgumentException("Invalid Arguments");
		}
	}

	public User getBuyer() {
		return buyer;
	}

	public User getSeller() {
		return seller;
	}

	public int getQuantity() {
		return quantity;
	}

	public Date getDate() {
		return date;
	}

	public Product getProduct() {
		return product;
	}	

	@Override
	public String toString() {
		return "Transaction [transactionId=" + getId() + ", buyerId="
				+ buyer + ", sellerId=" + seller + ", quantity=" + quantity
				+ ", date=" + date + "]";
	}
	
}
